import QtQuick 2.4
import QtQuick.Controls 2.14
import Qt.labs.platform 1.1
import QtQuick.Controls 1.4

Item{
    id:_item
    property alias model : _xtv.model
    Item {
        anchors.fill: parent
        anchors.margins: 20

        // select path:
        Item{
            id:_it
            anchors.top: parent.top
            anchors.left: parent.left
            anchors.right: parent.right
            height: 50

            Button{
                id:_btPath
                anchors.top: parent.top
                anchors.right: parent.right
                width:120
                height: _tfPath.height
                text: qsTr("Select Path")
                //font.pixelSize: 14

                onClicked: {
                    _folderDialog.open()
                }
            }

            TextField{
                id:_tfPath
                anchors.top: parent.top
                anchors.left: parent.left
                anchors.right: _btPath.left

                anchors.rightMargin: 20
                height: 30
                //24
                placeholderText: qsTr("File Path...")
                font.pixelSize: 14
                font.family: "Segoe UI"
            }

            FolderDialog {
                id: _folderDialog
                options:FolderDialog.ShowDirsOnly
                folder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
                onAccepted: {
                    var strTmp = _folderDialog.folder.toString()
                    _tfPath.text = strTmp.replace("file:///","")
                    _item.model.setDir(_tfPath.text)
                }
            }

        }


        XTreeView{
            id:_xtv
            anchors.top: _it.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.bottom: parent.bottom

            TableViewColumn{
                title: qsTr("File Name")
                role:"name"
                width: 300
            }
            TableViewColumn{
                title: qsTr("File Size")
                role:"size"
                width: 100
            }
            TableViewColumn{
                title: qsTr("File Change Time")
                role:"changeTime"
                width: 100
            }
//                    model: [{text:qsTr("Key Features"),color:"#818a99",size:"1MB",time:"2020-1-1 10:50:00"},
//                        {text:qsTr("Free"),color:"#037dff",size:"3MB",time:"2020-2-1 10:50:00"},
//                        {text:qsTr("Professional"),color:"#ff5700",size:"5MB",time:"2020-3-1 10:50:00"}]

        }
    }

}
